<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" placeholder="请输入1-100之间的整数">
<input type="button" value="猜一猜" onclick="f()">
<h1>结果:<span></span></h1>
<script>
  let x=parseInt(Math.random()*100+1);
  console.log(x)
  let i=document.querySelector("input");
  let s=document.querySelector("span");
  let count=0;
  function f() {
    count++;
    if (x>i.value){
      s.innerText="猜小了"
    }else if (x<i.value){
      s.innerText="猜大了"
    }else{
      s.innerText="恭喜你第"+count+"次猜对了!"
    }
  }
</script>
</body>
</html>